package com.softkey;

public class SoftKey5 {

	jsyunew3 j9;
	SoftKey5()
	{
		j9=new  jsyunew3();
	}

	private String myhex(byte indata)
	{
		String outString;
		outString=String.format("%X",indata);
		if(outString.length()<2)outString="0"+outString;
		return outString;
	}

	//��ĳ�ֽ�Ϊ�������轫��ת���޷�������
    private  long conver(byte temp){
        long tempInt = (int)temp;
        if(tempInt < 0){
            tempInt += 256;
        }
        return tempInt;
    }

	 //�������ڽ�16�����ַ���ת��Ϊ�޷��ų�����
    private int HexToInt(String s)
    {
        String [] hexch = { "0", "1", "2", "3", "4", "5", "6", "7",
						       "8", "9", "A", "B", "C", "D", "E", "F"};
        int i, j;
        int r, n, k;
        String ch;

        k = 1; r = 0;
        for (i = s.length(); i > 0; i--)
        {
            ch = s.substring(i - 1,  i-1+1);
            n = 0;
            for (j = 0; j < 16; j++)
            {
                if (ch.compareToIgnoreCase(hexch[j]) ==0 )
                {
                    n = j;
                }
            }
            r += (n * k);
            k *= 16;
        }
        return r;
    }


    public String  StrEnc(String InString , String Key)//ʹ����ǿ�㷨�������ַ���
    {

        byte [] b,outb;
        byte []temp_b=InString.getBytes();
        byte [] temp=new byte[8],outtemp=new byte[8];
        int n,i,nlen,outlen;
        String outString;

        nlen = temp_b.length;
        nlen=nlen+1;
        if( nlen < 8 )
            outlen = 8;
        else
            outlen = nlen;
        b=new byte[outlen];
        outb=new byte[outlen];

        for(n=0;n<nlen-1;n++)
        {
        	b[n]=temp_b[n];
        }

        outb=b.clone();

        for( n = 0; n<=outlen - 8 ;n=n+ 8)
        {
            for (i = 0; i < 8; i++) temp[i] = b[i + n];
            EnCode(temp, outtemp, Key);
            for( i = 0 ;i<8;i++) outb[i + n] = outtemp[i];
        }

        outString = "";
        for (n = 0 ;n<= outlen - 1;n++)
        {
            outString = outString +myhex(outb[n]) ;
        }
        return outString;
    }

    public String  StrDec(String InString , String Key)//ʹ����ǿ�㷨�������ַ���
    {

        byte [] b,outb;
        byte [] temp=new byte[8],outtemp=new byte[8];
        int n,i,nlen,outlen;
        String outString,temp_String;


        nlen = InString.length();
        if( nlen < 16 ) outlen = 16;
        outlen = nlen / 2;
        b=new byte[outlen];
        outb=new byte[outlen];

        i = 0;
        for (n = 1 ;n<= nlen ;n=n+2)
        {
            temp_String = InString.substring(n-1, n-1+2);
            b[i] = (byte)HexToInt(temp_String);
            i = i + 1;
        }

        outb=b.clone();

        for( n = 0; n<=outlen - 8 ;n=n+ 8)
        {
            for (i = 0; i < 8; i++) temp[i] = b[i + n];
            DeCode(temp, outtemp, Key);
            for( i = 0 ;i<8;i++) outb[i + n] = outtemp[i];
        }

        outString=new String(outb);
        outString=outString.trim();
        return outString;
    }

	public void EnCode(byte[] inb, byte[] outb,  String Key )
    {

		long cnDelta,y,z,a,b,c,d,temp_2;
		long [] buf=new long[16];
       int n,i,nlen;
       long sum;
       long temp,temp_1;
       long mask=4294967295L;

       //UInt32 temp, temp_1;
       String temp_String ;


       cnDelta = 2654435769L;
       sum = 0;

       nlen = Key.length();
       i = 0;
       for( n = 1 ;n<= nlen ;n=n+2)
       {
           temp_String =Key.substring(n-1, n-1+2);
           buf[i] =HexToInt(temp_String);
           i = i + 1;
       }
       a = 0 ; b = 0 ; c = 0 ; d = 0;
       for(n = 0;n<=3;n++)
       {
           a = (buf[n] << (n * 8)) | a;
           b = (buf[n + 4] << (n * 8)) | b;
           c = (buf[n + 4 + 4] << (n * 8)) | c;
           d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
       }


       y = 0;
       z = 0;
       for(n = 0;n<=3;n++)
       {
           temp_2 = conver(inb[n]);
           y = (temp_2 << (n * 8)) | y;
           temp_2 = conver(inb[n + 4]);
           z = (temp_2 << (n * 8)) | z;
       }


       n = 32;

       while (n > 0)
       {
           sum = (cnDelta + sum)& mask;

           temp = (z << 4) & mask;
           temp = (temp + a) & mask;
           temp_1 = (z + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (z >> 5) & mask;
           temp_1 = (temp_1 + b) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (temp + y) & mask;
           y = temp & mask;
           /*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */

           temp = (y << 4) & mask;
           temp = (temp + c) & mask;
           temp_1 = (y + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (y >> 5) & mask;
           temp_1 = (temp_1 + d) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (z + temp) & mask;
           z = temp & mask;
           /* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */
           n = n - 1;

       }
       for(n = 0;n<=3;n++)
       {
           outb[n] = (byte)((y >>> (n * 8)) & 255);
           outb[n + 4] =(byte)((z >>> (n * 8)) & 255);
       }
    }

	public void DeCode(byte[] inb, byte[] outb,  String Key )
    {

		long cnDelta,y,z,a,b,c,d,temp_2;
		long [] buf=new long[16];
       int n,i,nlen;
       long sum;
       long temp,temp_1;

       long mask=4294967295L;

       //UInt32 temp, temp_1;
       String temp_String ;


       cnDelta = 2654435769L;
       sum = 3337565984L;

       nlen = Key.length();
       i = 0;
       for( n = 1 ;n<= nlen ;n=n+2)
       {
           temp_String =Key.substring(n-1, n-1+2);
           buf[i] =HexToInt(temp_String);
           i = i + 1;
       }
       a = 0 ; b = 0 ; c = 0 ; d = 0;
       for(n = 0;n<=3;n++)
       {
           a = (buf[n] << (n * 8)) | a;
           b = (buf[n + 4] << (n * 8)) | b;
           c = (buf[n + 4 + 4] << (n * 8)) | c;
           d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
       }


       y = 0;
       z = 0;
       for(n = 0;n<=3;n++)
       {
           temp_2 = conver(inb[n]);
           y = (temp_2 << (n * 8)) | y;
           temp_2 = conver(inb[n + 4]);
           z = (temp_2 << (n * 8)) | z;
       }


       n = 32;

       while (n > 0)
       {


           temp = (y << 4) & mask;
           temp = (temp + c) & mask;
           temp_1 = (y + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (y >> 5) & mask;
           temp_1 = (temp_1 + d) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (z - temp) & mask;
           z = temp & mask;
           /* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */

           temp = (z << 4) & mask;
           temp = (temp + a) & mask;
           temp_1 = (z + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (z >> 5) & mask;
           temp_1 = (temp_1 + b) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (y - temp ) & mask;
           y = temp & mask;
           /*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */

           sum = (sum-cnDelta)& mask;
           n = n - 1;

       }
       for(n = 0;n<=3;n++)
       {
           outb[n] = (byte)((y >>> (n * 8)) & 255);
           outb[n + 4] =(byte)((z >>> (n * 8)) & 255);
       }
    }

	public  long get_LastError()
	{
		return j9.get_LastError();
	}

	public String FindPort(int start)
    {
        return j9.FindPort(start);
    }

   public int CheckKeyByFindort_2()
    {
        //ʹ����ͨ�㷨һ����ָ���ļ�����
        String DevicePath = ""; //���ڴ�����������ڵ�·��
		DevicePath = j9.FindPort_2(0, 1, 280120506);
		int ret = (int)j9.get_LastError();
		j9.CloseUsbHandle(DevicePath);
		return ret;
    }


    //ʹ�ô����ȵķ�����ָ���ĵ�ַ��ȡ�ַ���
    private String ReadStringEx(int addr, String DevicePath)
    {
        int nlen, ret;
        byte[] buf = new byte[1];
        //�ȴӵ�ַ0������ǰд����ַ����ĳ���
		ret = j9.YReadEx((short)addr, (short)1, "878BDB66", "B49273A8", DevicePath);
        if (ret != 0) return "";
		nlen = j9.GetBuf(0);
        //�ٶ�ȡ��Ӧ���ȵ��ַ���
		return j9.NewReadString(addr + 1, nlen, "878BDB66", "B49273A8", DevicePath);

    }
    //ʹ�ôӴ�������ȡ��Ӧ���ݵķ�ʽ����Ƿ����ָ���ļ�����
    public int CheckKeyByReadEprom()
    {
        int n, ret;
        String DevicePath = "";//���ڴ�����������ڵ�·��
        String outString = "";
        //@NoUseCode_data return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
        for (n = 0; n < 255; n++)
        {
            DevicePath= j9.FindPort(n );
            if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			outString = ReadStringEx(0, DevicePath);
			j9.CloseUsbHandle(DevicePath);
			if ((j9.get_LastError() == 0) && (outString.compareTo("ABC") == 0))
			{
				return 0;
			}
        }
        return -92;
    }
    //ʹ����ǿ�㷨һ�����������������������Ч�ط�ֹ����
    public int CheckKeyByEncstring()
    {
        //�Ƽ����ܷ�����������������������������㣬ͬʱ�ڳ����ж�ʹ�ô�����ͬ���ļ������㣬Ȼ����бȽ��жϡ�

        int n, ret;
        String DevicePath = "";//���ڴ�����������ڵ�·��
        String InString;

        //@NoUseKeyEx return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
        int number1=(int)(Math.random()*65535)+1;
        int number2=(int)(Math.random()*65535)+1;

        InString = (new   Integer(number1)).toString() + (new   Integer(number2)).toString();

        for (n = 0; n < 255; n++)
        {
           DevicePath= j9.FindPort(n );
            if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			if (Sub_CheckKeyByEncString(InString, DevicePath) == 0)
			{
				return 0;
			}
        }
        return -92;
    }

    private int Sub_CheckKeyByEncString(String InString, String DevicePath)
    {
        //ʹ����ǿ�㷨һ���ַ������м���
        int ret;
        String outString = "";
        String outString_2;
		outString = j9.EncString(InString,DevicePath);
		if (j9.get_LastError() != 0) return (int)j9.get_LastError();
		outString_2 = StrEnc(InString, "B8785ACE7AECB5FFE5262E9D77226F81");
        if (outString_2.compareTo(outString) == 0)//�ȽϽ���Ƿ����
        {
            ret = 0;
        }
        else
        {
            ret = -92;
        }
        j9.CloseUsbHandle(DevicePath);
        return ret;
    }

	//ʹ����ǿ�㷨������Ƿ���ڶ�Ӧ�ļ�����
	public int CheckKeyByEncstring_New()
	{
		int n, ret;
		String DevicePath = "";//���ڴ�����������ڵ�·��
		String outString = "";
		int myrnd = (int)(Math.random() * 500);
		String[] EncInString ={ "31888","9184","22591","29750","19727","13389","16705","2652","14121","4198","32190","649","26026","24523","7893","4465","635","19649","11707","869","28837","22057","13773","7768","9813","16772","28291","9179","9938","11509",
"1402","29473","7303","16701","2153","19196","4862","959","28458","11230","20705","18556","17850","23000","20987","17432","30256","32412","24885","15827","13000","27518","21145","24975","32730","31598","23889","12751","24034","5375",
"5543","6581","4985","19554","1798","7938","5977","9578","28149","13337","6749","30088","4642","10748","12669","26063","16469","16972","8148","5362","25719","24907","16541","22848","17300","24541","4401","8877","21973","32130",
"23305","31946","16516","29276","32192","12491","28683","8495","22802","1920","20981","26971","22230","11099","12010","6371","5384","10863","9398","32359","12224","6254","16450","6957","11066","20649","14231","29971","32206","22547",
"17377","2206","14840","24382","7018","23277","22609","25691","2970","11204","8595","30013","13052","18309","14488","4438","23354","31025","17498","11191","29471","7276","14836","19730","10388","20342","18078","21947","8867","17713",
"22964","24482","23413","14112","20143","16474","6743","30565","14121","11028","3504","8897","17628","29346","1292","29335","21410","27512","19219","12009","4981","28070","8081","16472","21103","30431","20846","25127","26315","27764",
"30902","29751","14562","32088","20626","27915","27949","9245","12620","27589","11848","18676","10831","27174","5869","945","15395","3730","15348","32194","12915","7688","22104","29757","7690","3628","3380","22995","28368","14144",
"24512","6358","11729","9766","12120","30007","22326","3679","26996","3721","21577","23565","20912","509","5493","26099","27589","11366","19522","16243","1422","3126","17755","10895","24834","17277","25227","10728","32319","14832",
"13499","12993","1405","24287","13813","32507","20757","2878","9059","32537","6019","925","30542","27709","13664","6702","803","31272","5990","28867","10602","10558","17519","23248","14284","14462","1910","24421","24852","14220",
"14739","23349","22317","14506","11266","17041","1312","8890","12827","877","26903","9021","19290","1880","3676","16469","27991","21894","10073","2758","28110","21705","18329","28655","3225","11667","15812","11221","7601","19444",
"3494","23320","21295","418","2600","11515","10062","18411","3924","13664","26217","8643","23635","24263","22776","7612","3442","31829","3480","30726","13848","31690","17152","23670","6864","14218","29194","18557","2885","26772",
"30643","3373","23615","14476","24338","28981","426","29620","19299","29420","18575","23277","511","10817","12568","5563","5216","19143","26766","17469","10784","17839","25438","12600","27384","3020","5904","9228","2245","28559",
"21581","21179","27006","9996","16608","29672","28990","28146","29108","28885","27712","18326","9426","14180","6365","24808","7012","11286","20878","4731","5044","15373","22255","640","25388","3853","14777","26313","12375","22901",
"25798","26314","19677","20042","18193","7572","12170","12589","7602","15319","3655","2143","24036","18919","6174","28353","16130","2487","20280","1497","25733","30934","738","1990","10247","29304","27010","31049","835","29039",
"23206","31687","6673","29228","10486","16193","25707","29890","7227","5209","30829","7908","2913","7760","29777","32224","5745","9480","2161","26797","149","1796","8516","474","10775","19301","12647","22937","10849","21487",
"7059","12221","2558","12034","15522","21943","7318","2465","5519","12442","31476","16749","5490","23320","7427","5801","903","26498","5068","32309","2342","16844","25465","5015","23499","12677","32083","10990","1807","31713",
"22983","764","22188","9650","12893","5924","24700","21866","23486","4456","11897","21786","16310","23656","2238","13429","30509","21865","24451","2764" };
		String[] EncOutString ={ "2933B20A347E9D0D","BA3379D959CBD97F","FA8331360F3AB3F4","C6E8F3EEF342A471","8BD0AB2E1B53B9A2","33EC24FAD4A3587B","09293338F94FF6EB","36F79BC37510C07B","B354449B2EB7EA9F","83F30BAA2DB9CDA7","3F0EBBED7C40AC5A","BD7837FD0034B87B","42311FBB3D479A47","78FEE1390AE91B60","0E6D859B4F7DF748","EDB39381E1FD4A22","4BB5A250CBD4444F","3D4F17E5545DB238","228ADDEBD68E1D70","034AD77E4F3DF151","B5A91B2741EA06D1","16E365B1583A91F0","85D85CEA735FF62C","467975E53887AA04","C64D3633ECA8C360","052B3C10201AF334","AFB3825C384D64F5","33D90F2977A6FE7E","72D13211429EC846","6E19314820575C2D",
"7D51C7EA0583DCF3","EC6094331AC94873","41E8444A205FD25A","130AEBD8BEF65E7A","27B329DACD89795A","203931526E1B5E14","BA3701256EFDD8B4","EA84EA45E3008A02","EF804CB7434B25E0","0564D18EA22A51B9","7276107671936BAC","772E55383F67EEED","22A7882886AA60C1","0DD2794516E16E0B","C2B7558E95DD27AF","F6FD2E94E2AB2DA6","04A9A04EDD77886E","D90FBB9BC569B880","957BC601EB87ED41","AF3E75625911C506","70CFCFCBBAB5F2FC","8292885DC5AA428C","4D3317622C92E141","3358E98906A7E1B2","EC0CB1FE62DA7F11","073BC3D79C0D2452","DE78141385414DB9","170A616FD844563A","8E768F7782663608","5F6D54F3667A077F",
"09D234E69F971862","C574355F228B5346","6181C8AEF0DD3FE2","93E03974FE27BE5F","A2757EC878371072","2C330CE773985AB5","AFD65FBAF45BEC7C","F0935A31A244100A","D10145A943CBD662","E29E581A35761474","8B7B15F85E092202","D97095E09647E49F","284D1AE25E10ABDB","340844EFEF09C6B4","710362AB7FFAF1C1","3FFBF8780450A11D","9D4EF89274C0C55B","0A48DCE878369A26","8AB575494038AE3C","4321E53094AD7F8E","B8F1E17E9950A70C","8D2B90F385FB1222","D48F1DB9B91A76A3","9BBE86AEB94A4086","BBABCCBA7FEEFF6E","44987F9EB2C3552E","BD58ADEFB9D74452","1D4B230B7A65A89A","9E1DAA646AC777EF","643C959E58680E97",
"DFEFF06768076B03","E905B82459EB45EA","039E100CC5D61435","B1A171D8CF6BEB15","76AED3C651A25395","FD407C335CECFCA5","2269A6B29B54790C","615EBFA18617492E","834BF021B73F8E1B","D1597714189CB6A9","D71B5E3040949F6B","048C2A7BF2415F0F","B9F478C56E007B23","F64C71723C8142D1","69F480EC81E5AFF1","392F9DB127F4F936","A224D85940C831A0","87619E4627893A17","74A1716F95221237","EDCEEF8322802404","6793646670B793E9","A10F460D28F82D1E","324112D693FDC39A","F3F1C813EB77F54F","BE4EFC5013130E25","4EC9EB5019153031","C5DC05147A2876EA","5D9437E9BF5AAE4E","3086BC53C0064C12","50B312EB456C8F00",
"63F749758DCC8BA9","B8A40C007C3F2CF9","82651B655CD03FF8","0B36B2C5C08EE0F8","FEC1C5FD36B834C4","4318B9B5599CC891","2082C79C715BCC18","2A3119D998ACD22D","49629E0ACD24C347","2AE694A4A641CD67","EA381B9E09AA1601","43149C6513BF67AF","1A243EA1CD0CAE5C","BFF0039D8240B3B1","734A277403294D39","7DB5595820D6BB14","C91DFEC1D71EFB75","0194A043629F4DF2","E15FB5C9A8A48433","EC5901D1720DCFDF","EF15E8D8A73507AD","99E470197796A850","42D4FCAF4B3959BB","628FB3E39C1FF701","6990435B621B51D1","008F81AE12F4D47C","4322E72F8FAF4412","EB79D5EE991B04BC","D1EE6C36A1C6715D","FEBA5748D2ACC3C2",
"CA159793B9EC5F9D","BEA185E5E2CF9BB6","79CE5F9EA3E1A08A","921127AFE1FB55D9","1EBF57EBAFA13B98","102C56B441E06D0A","75884A0A4C76803D","2C191AD042655A83","B354449B2EB7EA9F","DE0F855BFA8C9D97","A68DAF834D7E36E3","F4E9A26BA885E1EB","94CE2A0838884B97","D643528D99E342BA","75FBA2F9D4797D6A","C96575724B5D4A1F","42299CF05784F4B3","98497C4111789B36","74BAE3DB86E4F0ED","8C65CD078562AE48","71DCD6C44BFD9C35","A0480CB0D113787C","0E457034BDB909C4","65B3371C6069BE04","6BBECD4F18CFC2CF","B41ABA83634DBAD3","EA202055E8D2C127","C415E12565B07B27","3939F108A4802D71","61E0037D787E3BE0",
"116AB1ED5CEAA837","EF0FC9EE1409FD06","844F2D9B66427E3A","29EE0AF441F597E1","4FB4D01444BB502A","686752A69BB443E4","EF0806E116CCED11","D3BDEAA4E957607A","57817246F2FB226F","4A5E00C99EDBF610","F880EDADA0EACB84","7B4B47BADC97B51D","4BE86E85F90EB02F","7687E5348C960016","A9D025694600AFEC","E4D5CE0E73FAA9CC","0C74AC26B2C6BEC4","F8AF226A8A5E6059","D5469C4025C144D8","A1CAE7BD44F7EBE4","44A316728090FA39","BDD8F8ECFC4DDFC6","FD43DB42CE324260","9E5E4B61B19ACAD2","0FD274D317734DFA","6799920A01B4BF70","6C3501621702249C","F16CFA1BC375000E","5B079DC574140C0E","B3517340A5A92F79",
"22C19CEEDA4D3660","3000261DEAAF8006","DB98B198354BF59C","FC071EBBD1335252","50E22A74CAC2220D","20D4BE7AF6B408A7","C8DB84DD0C002FA3","17F6474AC0C6A5FF","4B80C99A99B9B6D3","4201C9E4357725AC","633A3012DC89019E","7FD9E25629CF1CAD","F135BC5F399BFC79","06A37EA35221A7F3","63E9E19A0E398BAC","55195DE810BC320B","4A5E00C99EDBF610","D9BED7A6F5787F68","0215D3E998CAC513","60E799CF0946EF0D","0FDA4D8002860D31","E6CEA087E4C0878D","27C58D2AAA04D9C8","A9B59EB60F427D80","BBFC7E1057B0CF13","95401E9CD4E98E20","009A2099895DD248","F15A638C348CA800","C5DC686E9332F291","9B308CE5047EBAD8",
"30257EBD1FEFA272","8BD8F4DF2FABD9B0","CBA0DADFD9FA488E","6E98E263AA64F314","09509F2AEE1FD345","FE79CB393B0E9E99","E45A2EDD8BB6D615","D8912896ADF512F3","20C7B84BC41A07B9","529FDE372BBB78EC","5FC2D2CF08A2BAD4","5394451B82A443C0","766E54D30D24DF05","CF8536A3E47DB9B9","057068EF93D1C26A","14BCA362DB605420","83676C7242A15386","97AC331058A895AF","97C33136B851C831","0009465609E0FE84","8CA6E2FFCE4DA09F","BC1122A2770133F8","511FECBC534C082A","996362E58626F577","7FEB7E8E4E5D3085","6D0DCF79D550A305","04960EC4AD1EFA14","24B1F4B87DDC0E29","0C252A9414265C53","EEB53CB6490CE300",
"6C1D61B0F1E8FC6A","834DBA230F44DD63","2B48D22F84D64C57","26B0064A98C86E94","51B0A3181ABBCF0C","843F086D79DA8EDB","EB6CDDBEF741C9AC","E06A90E930391E65","53118B7C5FE310B7","9837ACD809651525","6343AA6BE0FB7E3D","6ACD528E1C08C947","7D5C4DDDA4DAF83D","E247B562B9B3F03A","FCDE22440A7F0A57","9D4EF89274C0C55B","FCD6A6F3C6D25D21","55002CB814A87EF2","EACD4CCB44BB583D","6FB2C93D5609591F","1288CCA7E712B3DB","8408B6A613DA8950","3D6703708F7DE8DD","1BAFC735D86F92FF","5E9041F5122B428A","2A68CD1DE12EE41C","0BA6C3A70AB9D632","BB085BCEF66FF766","F1EB90E100C0522B","6A7A28060ABC8BE0",
"0B5E9D5BBF61BE75","D837F88CABD586AE","1D9DFB62204D50A3","B7AE153B36AB3C5D","093B6E4DB3759A43","E7066C432762888D","78EBDD6B16E10D32","4C3030FA5C3229A9","1EF048CD1D7B6426","057068EF93D1C26A","B2C84FCF0572599E","F60C2503B1460242","82B4A0CDCB018FDA","A9987C7B385E29B4","BB1CD38F2F86319D","B14D0356B369DE0C","53C51558B7800C5A","710F5AA2E4A0646C","8B1CF3EFABECC7B3","8750A0E536F2379A","EAD64DA2CA526A44","56868D8C20C53A4F","4A1731FA16E8125C","085026C2447EE622","E8A5AD4E4B0E3CB5","2C5E1598ECC5D63E","A0202D21B114253F","4CCEE9EB262622D7","4B71503FE75D9238","E94544801202D317",
"818CB9E99F19D77F","894B6DCE8B40E6BF","B9894CA0F4C4B4D3","A6B01CE1DEEA5265","57C5D1A1AAF4E1E9","6712B6D04400DEA3","EE8958B8208214DC","44A9285580B3A17E","2234003DF5BDBBB1","FE4F6856354F8364","585676EB9E31F372","4318B9B5599CC891","8F3C499D90CF5997","F6F0FFC186A42317","3BBD785C55CEF0AB","C26C2F910AFB4F82","1557E81CEF2DF342","204EC005A3E2F79E","7E15607260134E78","9F28D630198EA8B4","5E8AAA1423C5A062","3357D094E232EECD","4F753B7B3A70BD5B","9FE51D49EFE4771E","48BCCF68EABA1440","23DE454FAE31E596","D6A6FA7C41F7A9DC","8C0D91C153022BB7","20BB7CFFBA6F5DBD","3E19C9D8F9E2DAAD",
"8B31F23AFDEB9C71","665ABD7703ACDDA6","6E991B6C45531B4B","5E6376D509FE7207","D87813C895DDECBB","9CC4C6CE31BD0B55","B7119A1191B68BEA","ADB3F0756DA11341","E8A5DE68913847F5","FC8454B4F605B9AC","8CFC2787C76D548A","BCCFC1FA91B08180","B487547FE201EA94","2AC75A7B8880C64A","1A10DAE79573137C","D4FB516E4DA25207","3492E6884B397AC0","4C9D70C2255DF5A9","A7F483C4531B23EE","A7D556A8AE2EDE62","7102A9EF4CB88553","B623146F2751B757","1B008AB187B1E2A3","6B4A80714DE0FD34","46B2BD1A38C66138","79AAD194DA49C72E","5063920996B05233","4A99FEBF3C36C59A","B5CEDD53EA1EFCA4","DDE8D9D5682645F6",
"D886706AC3182779","E7D4661A64712655","F30B4CDA29525ACF","873E9307C0A6DE6B","A405D46EAE0B4792","3A1EFD2FA6087828","5E6F9F79C499D571","A05C54FF6471B4EE","8D26125C123FFC8A","035010B737FBADC6","802D4DD70530398D","1E238C276177F220","E421E3D6BA0A920B","40AEEE662BBF7A4F","40F2F28B807F179B","087ED49CE07B0329","301D4C4A84BFAC0C","0FDF10ADAF4A415E","9B422681C9B7378D","B290438F1EE37454","A38561C66B91D4D5","E7746C8CCDFF13C0","E3E70919DCF685B9","F452E7C53EF10F0F","B166221B57277791","48E3093594AA776E","0E99515B01B71442","4764497AB67C3A3A","2030D215DB8BCA93","6EAB761B17776265",
"3609C304F2A1CFB9","F620EABB19B9686A","E08A3C564A034E69","33A3E9B0FF15CB0E","515B073CF37F4937","05BD495CEC59605B","23CBF4E4F27027F9","402B2B92ECC3486A","E6CD5DDF2E56B36F","4520D7A2B5796DE9","A3B04EB0875C91CD","B2B3952EFE2E5618","2152C2CBF11146AF","C4D12AB8484FBB1C","B6ABDC08D507F80C","09908DE27A75BDA1","ECF2BC6CE148B66C","4064CCC0DFD25605","1A383180F1771126","0663C3A50EA1B364","C300A37342AB8250","21C58F9D628842D3","EFB79A4E81FDB37F","66075997E28BA4C8","59C3233F3ADB49A2","32B173A97F232468","7E00DF0DAE98661D","3229E59C542544B8","73B7FC3546FE84AB","21DD7122F6B7F3E9",
"17C0F9476E1D77C0","8256ADCAD35D92BE","C81AB856A9545822","17FF70755F407C96","B731C35E0F8D3D24","0C5D2DCE77989A53","732149AD0414849A","05503380F56336A9","14C434363C0656A3","A123C741E0218B5A","1A53150278EEBC94","35F84ADD45D98661","545C5D6195EBCA22","D837F88CABD586AE","AF39B0301073F15D","D9B1302BF79A29C4","74DE0D0E49D8BA40","84C75F968612EFD7","1E6DD1A63D55CFEC","032D04E998861AFC","8DC0A1FFA749967C","2976B3E6EE3BBC0E","7B869D389B36D9EA","136D2F63522E5FB0","CDCCC244568406DD","9A56484292B9720D","4362765FA9E7FEB9","1D4ADDF2950C262E","78EED6B39B41BDF9","5BDE1B4BAFB125F8",
"C8669519B4D9515A","0F31C2CE936023F3","129AF00E43DBFF75","E5F707F39A94B284","7D654904C3D960AD","74642BD8CBCBC259","3958EF018AE8BD6B","38356D78F543A266","42761FF6005B530A","2896BC8812E66A18","798A7252CA99C6DF","68D1E847FBD7643A","25E433994D854D28","6A95CEEAF481DD62","31C41947735D66CB","6BFA39ECFC18C622","A9C20BDF5F2FE308","F74FBF64A3E4C8F0","85E42089AC741F4B","D23C230D8D2E32BC" };
		//@NoUseNewKeyEx return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
		//@NoSupNewKeyEx  return 2;//���������֧��������ܣ�ֱ�ӷ���2


		for (n = 0; n < 255; n++)
		{
			DevicePath = j9.FindPort(n);
			if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			outString = j9.EncString_New(EncInString[myrnd], DevicePath);
			j9.CloseUsbHandle(DevicePath);
			if ((j9.get_LastError() == 0) && (outString.compareTo(EncOutString[myrnd]) == 0))
			{
				return 0;
			}
		}
		return -92;
	}


}
